home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Is this a C BUG??? (A string issue)
- Date: 1 Apr 1996 11:13:08 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jp9s4INNpp2@keats.ugrad.cs.ubc.ca>
- References: <4jknpf$9k3@abel.cc.sunysb.edu> <4jmjgfINN8pr@keats.ugrad.cs.ubc.ca> <AD84A72A96681716E4@mcdiala03.it.luc.edu>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <AD84A72A96681716E4@mcdiala03.it.luc.edu>,
- Verne Arase <VArase@varase.it.luc.edu> wrote:
- >In article <4jmjgfINN8pr@keats.ugrad.cs.ubc.ca>,
- >c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
- >
- > >When in doubt, process individual characters rather than being clever
- >with
- > >buffers and string manipulation. It can be more efficient and cleaner.
- >
- >Even better for fixed length records is open/read/write/close. You can even
- >use non-delimited records. (Why waste the space of a line delimiter, if
- >you're not going to use character formatted data?)
-
- You apparently glossed over the problem---can't blame you for that!
-
- What is being done is the conversion of non-fixed-length records to
- fixed-length records. I fail to see how using low-level POSIX functions would
- help, since you would have to pretty much duplicate what the standard IO
- library does for you anyway. In fact, you could set a large buffer size on the
- standard IO output stream which could cause it to output a whole bunch of
- 194-character records at once. A naive implementation of the program using
- write() would do the system call for each record.
-
- Under reasonable implementations, the putc(char, FILE *) function is a macro
- which quickly deposits a character into a buffer (taking advantage of actually
- knowing the representation of FILE), and conditionally calling a flush routine
- when the buffer is full. This is about as good as banging characters into your
- own buffer and calling write() when you fill that up, and it is portable, to
- boot.
- --
-
-